<?php

class Yourprofile extends Controller {

	function Yourprofile(){
		parent::Controller();
		$this->common_model->checklogin();
		$this->load->model('yourprofile_model');
	}	
	function index(){				
		$this->_loadview();
	}
	function editprofile(){
		$this->_loadview_update();
	}
	function changepassword(){
		$this->_loadview_changepassword();
	}
	function saveprofile(){
		$this->yourprofile_model->saveprofile();
		redirect('yourprofile','location');
	}
	function savepassword(){
		if($this->yourprofile_model->changepassword()){
			redirect('yourprofile','location');
		}
		else{
			$this->_loadview_changepassword();
		}
	}
	function _loadview(){		
		$data = $this->common_model->general();
		$data['bodyview'] = 'yourprofile/viewprofile';	
		$this->yourprofile_model->loadprofile();
		$data['username'] = $this->yourprofile_model->username;
		$data['firstname'] = $this->yourprofile_model->firstname;
		$data['lastname'] = $this->yourprofile_model->lastname;
		$data['phone'] = $this->yourprofile_model->phone;
		$data['email'] = $this->yourprofile_model->email;		
		$this->load->view('mastertemplate',$data);
	}	
	function _loadview_update(){
		$data = $this->common_model->general();
		$data['bodyview'] = 'yourprofile/editprofile';	
		$this->yourprofile_model->loadprofile();
		$data['username'] = $this->yourprofile_model->username;
		$data['firstname'] = $this->yourprofile_model->firstname;
		$data['lastname'] = $this->yourprofile_model->lastname;
		$data['phone'] = $this->yourprofile_model->phone;
		$data['email'] = $this->yourprofile_model->email;		
		$this->load->view('mastertemplate',$data);
	}
	function _loadview_changepassword(){
		$data = $this->common_model->general();
		$data['bodyview'] = 'yourprofile/changepassword';
		$data['errmsg'] = $this->yourprofile_model->errmsg;
		$this->load->view('mastertemplate',$data);
	}
}

/* End of file yourprofile.php */
/* Location: ./system/application/admin/controllers/yourprofile.php */